# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=libguess
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.2
pkgrel=4
pkgdesc="High-speed character set detection library (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
url="https://github.com/kaniini/libguess"
license=('custom')
depends=("${MINGW_PACKAGE_PREFIX}-libmowgli")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc" "${MINGW_PACKAGE_PREFIX}-autotools")
options=('staticlibs' 'strip')
source=("https://sources.archlinux.org/other/packages/libguess/${_realname}-${pkgver}.tar.bz2")
sha256sums=('8019a16bdc7ca9d2efbdcc1429d48d033d5053d42e45fccea10abf98074f05f8')

prepare() {
  cd ${srcdir}/${_realname}-${pkgver}

  sed 's/libmowgli >= 0.9.50/libmowgli-2/g' -i configure
}

build() {
  [[ -d "build-${MSYSTEM}" ]] && rm -rf "build-${MSYSTEM}"
  cp -rf ${_realname}-${pkgver} ${srcdir}/build-${MSYSTEM}
  cd build-${MSYSTEM}
  ./configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST}

  make
}

package() {
  cd ${srcdir}/build-${MSYSTEM}
  make DESTDIR="$pkgdir" install
  install -Dm644 COPYING "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE"
}
